<template>
  <div>
    <MusicListView title="推荐歌单" :recommend="recommend"/>
    <MusicRecommend title="推荐歌曲" :recommend="musiclist"/>
  </div>
</template>

<script>
import MusicListView from './MusicListView.vue'
import MusicRecommend from './MusicRecommend.vue'

export default {
    name: "MusicList",
    data(){
      return{
        recommend: [],
        musiclist: []
      }
    },
    created(){   //使用created或mounted生命周期来执行向接口请求数据的函数
      this.$api.getRecommend({limit:6}).then(res => {
        // console.log(res);
        this.recommend = res.result;
      })

      this.$api.getMusic().then(res => {
        // console.log(res);
        this.musiclist = res.result.slice(0,6);
      })
    },
    components:{
      MusicListView,
      MusicRecommend
    }
}
</script>

<style>

</style>